<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>登入</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <!--    引入css 样式-->
    <link rel="stylesheet"  href="/layui/css/layui.css">
    <!--    引入js -->
    <script src="/layui/layui.js"></script>
</head>
<body>

<div style="width: 20%;margin:20px auto">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-inline">
                <input type="text" name="name" required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>

    layui.use(['layer', 'form'], function() {
        var $ = layui.$,
            layer = layui.layer,
            form = layui.form

        form.on('submit(submit)', function(data){
            console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            $.ajax({
                url:  '/api/after/login.do',
                type: "post",
                data:data.field,
                success : function(data) {
                    window.location.href ="index.html" ;
                },
            })

            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        // form.render();
    })
</script>
</body>
</html>